package StringBuilder;

public class anli {
    public static void main(String[] args) {
        /*
        * 案例1
        * 对称字符串
        * */

        String s = "123321";
        String s2 = "123123";

//        System.out.println(isSame(s));
//        System.out.println(isSame(s2));
//        System.out.println(isSameTeacher(s));
//        System.out.println(isSameTeacher(s2));
        int[] arr = {1,2,3};
        String arrS = toggle(arr);
        System.out.println(arrS);
    }
    public static String toggle(int[] arr){
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < arr.length; i++) {
            sb.append(arr[i]);
            if(i!=(arr.length-1))sb.append(",");
        }
        sb.insert(0,'[').append(']');


        return sb.toString();
    }
    public static boolean isSameTeacher(String s){
        StringBuilder builder = new StringBuilder(s);
        boolean equals = builder.reverse().toString().equals(s); // 这里reverse的时候,记得toString,才能判断
        return equals;
    }
    public static boolean isSame(String s){
        int len = s.length();
        char[] sARR = s.toCharArray();
        if(len%2==1){

        }else{
            for (int i = 0; i < len/2; i++) {
                if(sARR[i] != sARR[len-1-i]){
                    return  false;
                }
            }
        }
        return true;
    }
}
